﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.DesignerPatter.Observer
{
    public class MyDelegate
    {
        public delegate void SayDelegate(string name);
        public void SayChinese(string name)
        {
            Console.WriteLine("你好，{0}",name);
        }

        public void SayEnglish(string name)
        {
            Console.WriteLine("hello，{0}",name);
        }

        public void Dowork(string name, SayDelegate MakeSay)
        {
            //switch (Lt)
            //{
            //    case LanguageTyp.chinese:
            //        SayChinese(name);
            //        break;
            //    case LanguageTyp.english:
            //        SayEnglish(name);
            //        break;
            //}
            MakeSay(name);
        }

        static void Main()
        {
            MyDelegate del = new MyDelegate();
            string name1 = "李世杰";
            string name2 = "lishijie";
            //del.Dowork("李世杰", LanguageTyp.chinese);
            //del.Dowork("lishijie", LanguageTyp.english);

            //del.Dowork("李世杰", del.SayChinese);
            //del.Dowork("lishijie", del.SayEnglish);

            //SayDelegate del1 = del.SayChinese;
            //SayDelegate del2 = del.SayEnglish;
            //del.Dowork(name1, del1);
            //del.Dowork(name2, del2);

            SayDelegate del1 = del.SayChinese;
            del1 += del.SayEnglish;
            del.Dowork(name1, del1);
            
            Console.Read();
        }
    }

    public enum LanguageTyp
    {
        chinese,
        english
    }

}
